package iscript.gameFramework.GameLite.events
{
	import flash.events.Event;
	import iscript.coreFramework.util.GUID;
	import iscript.gameFramework.GameLite.system.reflection.Reflection;
	
	public class GameEvent extends Event
	{
		
		private var _id:String;
		private var _splitChar:String = "$GameEvent$";
		private var _isReflection:Boolean;
		
		public function GameEvent(statictype:String)
		{
			//regsite(type)
			
			  var reflect:Reflection = new Reflection(this);
			  for each (var key:String in reflect.staticVariable.names)
			  {
			     reflect.staticVariable.set(key,key);
			  }
			
			_id = _splitChar + GUID.create();
			 reflect.staticVariable.set(statictype, reflect.staticVariable.get(statictype) + _id);
			statictype = reflect.staticVariable.get(statictype);
			trace("statictype>>>",statictype)
			super(statictype);
			//super(type, bubbles, cancelable);
		}
		
		
		/*private function regsite(type:String):void {
			if(!IsUnique(type)){
			  _id = _splitChar + GUID.create();
			  var reflect:Reflection = new Reflection(this);
			  for each (var key:String in reflect.staticVariable.names)
			  {
			     reflect.staticVariable.set(key, reflect.staticVariable.get(key) + _id);
			     type +=  _id;
			    }
			  }
		}*/
		
		public function get id():String
		 {
		   return _id;
		 }
		 

		
		public override function clone():Event
		{
			return new GameEvent(type);
		}
		
		public override function toString():String
		{
			return formatToString("GameEvent", "type", "bubbles", "cancelable", "eventPhase");
		}
		
		public function IsUnique(type:String):Boolean {
			   return  type.indexOf(_splitChar) != -1;
			}
		
	
	}
}